package com.hwd.srb.core.controller.admin;


import com.hwd.srb.common.constant.Constants;
import com.hwd.srb.common.result.R;
import com.hwd.srb.core.pojo.entity.UserLoginRecord;
import com.hwd.srb.core.service.UserLoginRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 用户登录记录表 前端控制器
 * </p>
 *
 * @author 黄伟东/Victor
 * @since 2022-03-10
 */
@RestController
@RequestMapping("/admin/core/userLoginRecord")
@ApiModel("后台管理登录日志接口")
@Api(tags = "登录日志管理")
@Slf4j
//@CrossOrigin
public class AdminUserLoginRecordController {

    @Resource
    private UserLoginRecordService userLoginRecordService;

    @ApiOperation("查询用户登录日志列表")
    @GetMapping("/listTop50/{id}")
    public R listTop50(@ApiParam(value = "用户的id", required = true, example = "1")
                                         @PathVariable("id") Long userId) {
        List<UserLoginRecord> userLoginRecordList = userLoginRecordService.listTop50(userId);
        return R.ok().data(Constants.LIST, userLoginRecordList);
    }
}

